/*
 * MyFileView.java
 *
 * Created on 19 de junio de 2006, 01:26 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package inc.jmc.cyberboard.common;
import java.io.File;

import javax.swing.Icon;
import javax.swing.filechooser.FileView;
/**
 *
 * @author Juan Miguel Olguin Salguero
 */
public final class ImagenesFileView extends FileView {
    /*private Hashtable icons = new Hashtable(6);
    public final void putIcon(String extension, Icon icon) {
	icons.put(extension, icon);
    }*/
    public ImagenesFileView()
              {
              //putIcon("jpg", PCTimers.images[PCTimers.JPG_FILTER]);
              //putIcon("gif", PCTimers.images[PCTimers.GIF_FILTER]);
              //putIcon("dxf", getImageIcon("dxficon.gif"));
              //putIcon("obj", getImageIcon("dxficon.gif"));
              //putIcon("3ds", getImageIcon("dxficon.gif"));
              //putIcon("wrl", getImageIcon("dxficon.gif"));
              //putIcon("mtl", getImageIcon("textureicon.gif"));
              }

    public final Icon getIcon(File f) {
	Icon icon = null;
        String extension = getExtension(f);
	/*if(extension != null) {
	    icon = (Icon) icons.get(extension);
	}*/
        if(extension != null) {
            extension=extension.toLowerCase();
            if(extension.endsWith("gif"))
            {
                icon=ImageLoader.images[ImageLoader.GIF_FILTER];
            }
            if(extension.endsWith("jpg"))
            {
                icon=ImageLoader.images[ImageLoader.JPG_FILTER2];
            }
        }
	return icon;
    }
    public final String getExtension(File f) {
	String name = f.getName();
	if(name != null) {
	    int extensionIndex = name.lastIndexOf('.');
	    if(extensionIndex < 0) {
		return null;
	    }
	    return name.substring(extensionIndex+1).toLowerCase();
	}
	return null;
    }
}